<@master template="/common/master"  title="首页-p2p金融">
    <@include file="/common/head"/>
  	<@head title="忘记密码" dColor="dlHeader"/>
    <form id="submitForm" role="form" action="/resetPwd/ajaxSubmit" class="form-horizontal" method="POST">
	    <div class="dlBox">
	    	<p class="wrong" id="errorText"></p>
	        <ul class="dllist">
	        	<li><span class="sjIco icon"></span><input name="mobile" type="text" placeholder="输入您的手机号码"></li>
	            <li>
	            	<a href="javascript:void(0);" onclick="reImg();" class="fr ml10">看不清，换一张</a>
	            	<img src="/common/getCaptcha" id="Img" class='fr yzmImg'>
	            	<input name="code" type="text" style="width:150px;" placeholder="输入图片验证码">
	            </li>
	            <li>
	            	<a id="obtainMobileValidateCode" href="javascript:void(0);" class="yzm fr">获取验证码</a>
	            	<a id="reSendMobileValidateCode" href="javascript:void(0);" class="yzm fr" style="display: none;"><span id="spanMsg">60秒后可重发</span></a>
	            	<span class="yzmIco icon"></span><input type="text" placeholder="输入你的验证码" name="smsCode">
	            </li>
	            <li>
	            	<span class="fr icon kjIco" onclick="showPw();">
	            	</span><span class="dlIco icon"></span>
	            	<input id="password" name="password" type="password" placeholder="设置您的新密码">
	            </li>
	        </ul>
	    </div>
	    <div class="btnBox">
	    	<a href="javascript:void(0);" class="tzBtn" id="submitBtn">确定修改密码</a>
	    </div>
    </form>
	<@js src="/js/p2p/investor/validate.js"/>
    <@js>  
    	var smsInterval = 60;
    	$(document).ready(function(){
    		$("#obtainMobileValidateCode").bind("click",function(){
				var _this = $(this);
				_this.disabled = 'disabled';
				setTimeout(function() {
					_this.disabled = 'disabled';
				}, 5000)
				$('#errorText').text('');
	    		var mobile = $("input[name='mobile']").val();
	    		var mobileCheck = $.fn.validate.mobile(mobile);
	    		if(!mobileCheck.isSuccess){
	    			$('#errorText').text(mobileCheck.errorMsg);
	    			return false;
	    		}
	    		var erifyCode = $("input[name='code']").val();
	    		if(!erifyCode){
	    			$('#errorText').text('请输入图片验证码');
	    			return false;
	    		}
	    		$.getJSON("/common/checkCaptcha",{captcha:erifyCode},function(result){
	    			if(result.data == true){
	   					$('#errorText').text('');
	   					$.ajax({
			    			url:"/common/sendAuthCode",
			    			dataType:"json",
			    			data:{mobile:mobile},
			    			success:function(msgResult){
			    				if(msgResult.data = true){
				    				$("#reSendMobileValidateCode").show();
									$("#obtainMobileValidateCode").hide();
									window.regSmsIntervalTimer = window.setInterval("smscountdown()", 1000);
			    				}
			    			}
			    		});
	   				}else{
	   					$('#errorText').text('图片验证码错误');
	   				}
	    		})
    		});
    		
    		$("#submitBtn").on("click",function(){
			    var mobile = $("input[name='mobile']").val();
	    		var mobileCheck = $.fn.validate.mobile(mobile);
	    		if(!mobileCheck.isSuccess){
	    			$('#errorText').text(mobileCheck.errorMsg);
	    			return false;
	    		}
	    		var password = $("input[name='password']").val();
	    		if(!password){
	    		    $('#errorText').text("密码不能为空");
	    			return false;
	    		}
	    		var smsCode = $("input[name='smsCode']").val();
	    		if(!password){
	    		    $('#errorText').text("短信验证码不能为空");
	    			return false;
	    		}
				$.ajax({
					url: $("#submitForm").attr("action"),
					type: "POST",
					data: $("#submitForm").serialize(),
					success:function(result){
						if(result.data == true){
							window.location.href='/login/index';
						}else{
							$('#errorText').text(result.data);
						}
					}
				});
    		})
    	});
        function reImg(){  
            var img = document.getElementById("Img");  
            img.src = "/common/getCaptcha?rnd=" + Math.random();  
        }  
        function smscountdown() {
			if (smsInterval <= 0) {
				window.clearInterval(regSmsIntervalTimer);
				smsInterval = 60;
				$("#reSendMobileValidateCode").hide();
				$("#obtainMobileValidateCode").show();
			}else{
				smsInterval = smsInterval - 1;
				$("#spanMsg").html(smsInterval+"秒后可重发");
			}
		};
		function showPw(){
		    if($('#password').attr('type') == 'password' ){
		    	$('#password')[0].type='text';
		    	$('.kjIco').addClass('bkjIco');
		    }else{
		    	$('#password')[0].type='password';
		    	$('.kjIco').removeClass('bkjIco');
		    }
		};
	 </@js>
	 <@jsRender/>  
</@master>